home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F35868_sqrt2.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-20  |  2.0 KB  |  57 lines

  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  2. xmlns:saxon="http://icl.com/saxon"
  3. xmlns:MyRepeatGenerator="MyRepeatGenerator" 
  4. xmlns:MyRepeatableFunction="MyRepeatableFunction"
  5. exclude-result-prefixes="xsl saxon MyRepeatGenerator MyRepeatableFunction" 
  6. >
  7.  
  8.   <xsl:import href="within.xsl"/>
  9.  
  10.   <MyRepeatGenerator:MyRepeatGenerator/>
  11.   <MyRepeatableFunction:MyRepeatableFunction/>
  12.   
  13.    <xsl:variable name="vMyRepeat" select="document('')/*/MyRepeatGenerator:*[1]"/>
  14.    <xsl:variable name="vMyFunction" select="document('')/*/MyRepeatableFunction:*[1]"/>
  15.    
  16.   <xsl:template name="sqrt">
  17.     <xsl:param name="N"/>
  18.     <xsl:param name="Eps" select="0.1"/>
  19.     
  20.     <xsl:variable name="vrtfParams">
  21.       <param><xsl:value-of select="$N div 2"/></param>
  22.       <xsl:copy-of select="$vMyFunction"/>
  23.       <param><xsl:value-of select="$N"/></param>
  24.     </xsl:variable>
  25.  
  26.     <xsl:call-template name="within">
  27.       <xsl:with-param name="pGenerator" select="$vMyRepeat"/>
  28.       <xsl:with-param name="pParam0" select="saxon:node-set($vrtfParams)/*"/>
  29.       <xsl:with-param name="Eps" select="$Eps"/>
  30.     </xsl:call-template>
  31.   </xsl:template>
  32.   
  33.   <xsl:template name="myRepeater" match="*[namespace-uri()='MyRepeatGenerator']">
  34.      <xsl:param name="pList" select="/.."/>
  35.      <xsl:param name="pParams"/>
  36.      
  37.      <xsl:choose>
  38.          <xsl:when test="not($pList)">
  39.             <xsl:copy-of select="$pParams[1]/node()"/>
  40.          </xsl:when>
  41.          <xsl:otherwise>
  42.            <xsl:apply-templates select="$pParams[2]">
  43.              <xsl:with-param name="X" select="$pList[last()]"/>
  44.              <xsl:with-param name="N" select="$pParams[3]/node()"/>
  45.            </xsl:apply-templates>
  46.          </xsl:otherwise>
  47.      </xsl:choose>
  48.   </xsl:template>
  49.  
  50.   <xsl:template name="myRptFn" match="*[namespace-uri()='MyRepeatableFunction']">
  51.      <xsl:param name="X"/>
  52.      <xsl:param name="N"/>
  53.      
  54.      <xsl:value-of select="($X + ($N div $X)) div 2"/>
  55.   </xsl:template>
  56.  
  57. </xsl:stylesheet>